<?php


namespace app\model;

use app\BaseModel;
use think\model\concern\SoftDelete;
class User extends BaseModel
{
    use SoftDelete;
    protected $autoWriteTimestamp = false;
    protected $deleteTime = 'delete_time';

    protected $defaultSoftDelete = 0;

    public function getLastLoginTimeAttr($value, $data)
    {
        if($data['last_login_time'] >0){
            return toDate($data['last_login_time']);
        }else{
            return '';
        }
    }

    public function login($username, $password)
    {
        $ret = $this::where('login_name', $username)->where('password', md5($password))->find();
        return $ret ? $ret : false;
    }

    public function dellogin($username, $password)
    {
        $ret = $this::where('login_name', $username)->where('password', md5($password))->where('del_flag',1)->find();
        return $ret ? $ret : false;
    }

    public function checkAccount($username)
    {
        $ret = $this::withTrashed()->where('login_name','=',$username)->find();
        return $ret ? $ret : false;
    }

}